package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * Created by xbb on 2019/10/15.
 */
@Getter
public enum WarehouseOriStockEnum {
    NOT_DONE("1","enum.warehouseOriStock.name.not_done","notDone"),
    NO_NEED("2","enum.warehouseOriStock.name.no_need","noNeed"),
//    UNKNOWN("","",""),
    ;
    WarehouseOriStockEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    private String code;
    private String name;
    private String attr;

    public static WarehouseOriStockEnum getByCode(String code) {
        for (WarehouseOriStockEnum cacheCode : values()) {
            if (Objects.equals(code, cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
